home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Structures.h
-
- Contains: Header for routines which deal with virtual sound hardware from a
- 'sdev' component.
-
- Written by: Mark Cookson
-
- Copyright: Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/16/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #ifndef __STRUCTURES__
- #define __STRUCTURES__
-
- #include <Files.h>
- #include <SoundComponents.h>
- #include <Timer.h>
- #include <Types.h>
-
- #ifndef __AIFFWRITER__
- #include "AIFF_writer.h"
- #endif
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Constants
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- #define kSoundComponentVersion 0x10000 /* version for this component */
- #define kSndFileName "\pSound 1" /* name for sound file data is written to */
- #define fsNoCache 32 /* set this bit to not use the cache in a PBWrite */
-
- #define kSecondsInIOBuffer 1 /* no. seconds of audio data in each I/O buffer */
- #define kHardwareBufferSize 512 /* size of hardware buffer */
- #define kDelegateSifterCall ((ComponentRoutine) -1L) /* flag that selector should be delegated instead of called */
-
- #ifndef kFix1
- #define kFix1 ((Fixed)(0x00010000)) /* 1.0 in fixed point */
- #endif
-
- #define kComponentWantsToRegister 0 /* component wants to be registered */
- #define kComponentDoesNotWantToRegister 1 /* component doesn't want to be registered */
-
- #define SoundComponentEntryPoint HackBlaster //Our entry point instead of __start
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Structures
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /* Data structure passed to some GetInfo calls */
-
- typedef struct {
- short count;
- Handle handle;
- } HandleList, *HandleListPtr;
-
- /* My time manager task record includes space for my globals at the end */
-
- typedef struct SoundComponentGlobals SoundComponentGlobals;
- typedef SoundComponentGlobals *SoundComponentGlobalsPtr;
- typedef SoundComponentGlobalsPtr *SoundComponentGlobalsHandle;
-
- typedef struct {
- TMTask task;
- SoundComponentGlobalsPtr globals;
- } myTMTask, *myTMTaskPtr;
-
- /* i/o buffer structure */
-
- typedef struct {
- ParamBlockRec iopb; // i/o parameter block
- long byteCount; // no. bytes in buffer
- Ptr buffer; // buffer for data
- Handle bufferHandle; // handle to buffer
- } IOBuffer, *IOBufferPtr;
-
- /* Component globals */
-
- struct SoundComponentGlobals {
-
- // these are general purpose variables that every component will need
- ComponentInstance sourceComponent; // component to call when hardware needs more data
- SoundComponentDataPtr sourceDataPtr; // pointer to source data structure
- SoundComponentData thisSifter; // description of data this component outputs
- Handle globalsHandle; // handle to component globals
- Boolean inSystemHeap; // true if component loaded in system heap, false if in app heap
- Boolean hardwareOn; // true if hardware is on, false if it is off
-
- // these are variables specific to this component implementation
- HardwareGlobalsPtr hwGlobals; // pointer to hardware globals
- unsigned long nextTime; // next time to interrupt
- unsigned long ioBufferSize; // size of i/o buffer in bytes
- long interruptInterval; // time in microseconds between interrupts
- myTMTask tmTask; // time manager task record used to trigger interrupt
- long headerLen; // length of AIFF header written to beginning of file
- short fRefNum; // fref of file to save data into
- short currentIndex; // current buffer to save data into
- IOBuffer ioBuffers[2]; // buffer descriptions
- };
-
- /* It is possible to debug this component using Think C. To do this, you cannot call the time
- manager to generate interrupts, since Think C is not re-entrant. This means you must call
- the FakeInterrupt routine described below during main event loop time, and define the
- FakeInterrupts variable. */
-
- #ifdef FakeInterrupts
- SoundComponentGlobalsPtr gGlobals;
- #endif
-
- #endif //#ifndef __STRUCTURES__